package com.alphawavesgames.engine.rendering;

import java.nio.Buffer;
import java.nio.FloatBuffer;

/**
 *
 * @author Duncan
 */
public class ElementStreamFloat extends ElementStream
{
    protected FloatBuffer m_buffer;

    private ElementStreamFloat()
    {
    }

    public ElementStreamFloat( int elemsPerBlock, int numBlocks, StreamType dataType )
    {
        m_elementSize = 4;
        m_numElemsPerBlock = elemsPerBlock;
        m_numBlocks = numBlocks;

        m_buffer = FloatBuffer.allocate( elemsPerBlock * numBlocks );

        m_dataType = dataType;
    }

    public Buffer getBuffer() { return m_buffer; }

    /*public void setBuffer( FloatBuffer buffer )
    {
        m_buffer = buffer;
        m_numElements = buffer.limit();
    }*/

    /*public void setBlock( int index, float value )
    {
        if( index >= 0 && index < m_numElements )
        {
            m_buffer.put( index, value );
        }
    }*/

    public void setBlock( int index, float[] values )
    {
        if( index >= 0 && index < m_numBlocks )
        {
            m_buffer.position( index * m_numElemsPerBlock );
            m_buffer.put( values, 0, m_numElemsPerBlock );

            //do we need to reset the position
            m_buffer.position( 0 );
        }
    }
}
